package com.hunlian.makelove.activity;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;

import com.hunlian.makelove.R;
import com.hunlian.makelove.view.CustomProgressDialog;
import com.hunlian.makelove.widget.address.AppManager;
import com.tencent.stat.StatService;
import com.umeng.analytics.MobclickAgent;

public class BaseActivity extends Activity {


    protected CustomProgressDialog progressDialog = null;

    protected void createProgressDialog(Context context){
        progressDialog = CustomProgressDialog.createDialog(context, getResources().getString(R.string.loading));
        progressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                //若是网络请求，则取消请求——但不能全部取消，防止多线程异步请求被取消

            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppManager.getAppManager().addActivity(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        StatService.onResume(this);
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        StatService.onPause(this);
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppManager.getAppManager().finishActivity(this);
    }
}
